import requests


class SendRequest:
    @staticmethod
    def send_request(url, method, params=None, data=None, json=None, headers=None):
        if method == "get":
            response = requests.get(url=url, params=params, headers=headers)
        elif method == "post":
            response = requests.post(url=url, data=data, json=json, headers=headers)
        else:
            response = None
            print("请求方法错误")

        result = {}
        if response is not None:
            result["status_code"] = response.status_code
            result["headers"] = response.headers
            result["body"] = response.json()
            return result
        else:
            return response


if __name__ == '__main__':
    url = "http://localhost:8080/admin/register"
    method = "post"
    body1 = {
        "email": "string@qq.com",
        "icon": "string1",
        "nickName": "string2",
        "note": "string3",
        "password": "123456",
        "username": "qwe"
    }
    print(SendRequest.send_request(url, method, json=body1))
